package cn.itsource.basic.util.job;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.annotation.Schedules;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
* 定时提醒类
* @author wangcp
* @date 2021/05/08 18:04
**/
@Component
public class TimingRemindTask {

    @Autowired
    private TaskService taskService;


    @Schedules({@Scheduled(cron = "3,23,26,34,46 * * * * ? ")})
    public void remindTask() throws InterruptedException {
        taskService.executeRemindMessage();
    }

    /**
     * 超时关单
     * 需求:超过30分钟未支付的订单,通过任务关闭
     * @throws InterruptedException
     */
    @Schedules({@Scheduled(cron = "0/10 * * * * ?")})
    public void closeOrder() throws InterruptedException {
        taskService.timeOutCloseOrder();
    }

    /*
    基础版本
    @Schedules({@Scheduled(cron = "0/10 * * * * ?")})
    public void remindTask(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("执行定时任务了,执行时间为：" + sdf.format(new Date()));
    }*/
}